<%--                                                                       --%>
<%-- Copyright (c) 2003 BroadVision, Inc.  All rights reserved.            --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import =  "java.util.HashMap,
                    org.apache.commons.beanutils.PropertyUtils,
                    org.apache.struts.validator.DynaValidatorForm"
%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<script language="JavaScript">
         
  function doCancel(theForm) {
    if (theForm != null) {
      var cancelAction ='<bean:write name="cmContentRoleEditForm" property="cancelAction"/>';
      theForm.action='<html:rewrite page="' + cancelAction + '" />';
      theForm.submit();
      return true;
    }
    return false;
  }

  function trimRoleFields(theForm) {
    var tmp = theForm.name.value;
    theForm.name.value = tmp.stringTrim();

    tmp = theForm.friendlyName.value;
    theForm.friendlyName.value = tmp.stringTrim();

    tmp = theForm.description.value;
    theForm.description.value = tmp.stringTrim();

    return validateCmContentRoleEditForm(theForm);
  }

</script>

<%
  java.util.HashMap map = new java.util.HashMap();
  DynaValidatorForm cmContentRoleEditForm = (DynaValidatorForm) request.getAttribute("cmContentRoleEditForm");
  map.put("oid", (Long) PropertyUtils.getSimpleProperty(cmContentRoleEditForm, "oid"));
  pageContext.setAttribute("pagetabParam", map, PageContext.PAGE_SCOPE);
%>

<html:javascript formName="cmContentRoleEditForm"/>

<html:form action="/cm/contentRoleSave.do" onsubmit="return (trimRoleFields(this));">

<html:hidden  property="oid" />
<html:hidden  property="cancelAction" />

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
        <div class="pageTitle">
          <logic:equal name="cmContentRoleEditForm" property="oid" value="-1">
            <bean:message bundle='cm.messages' key="cm.content.role.newRole"/>
          </logic:equal>
          <logic:notEqual name="cmContentRoleEditForm" property="oid" value="-1">
            <bean:write name="cmContentRoleEditForm" property="name"/>
          </logic:notEqual>
        </div> 

	<div class="errorMessage"><html:errors bundle='cm.messages'/></div>
        <%@include file="/mc/common/pagetab.jsp" %>

        <div class="pageSubtitle">
          <span class="left"><bean:message bundle='cm.messages' key="cm.content.role"/></span>

          <span class="right">&nbsp;</span>
        </div> 

        <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Role Content">
          <tr> 
            <td class="label" width="20%">
              <bean:message bundle='cm.messages' key="cm.content.edit.role"/>:
            </td>
            <td class="labelField" >
              <logic:equal name="cmContentRoleEditForm" property="oid" value="-1">
                <html:text size="40" maxlength="128" property="name"/> &nbsp;
              </logic:equal>
              <logic:notEqual name="cmContentRoleEditForm" property="oid" value="-1">
                <bean:write name="cmContentRoleEditForm" property="name" />&nbsp;
                <html:hidden property="name" />
              </logic:notEqual>
            </td>
          </tr>
          <tr> 
            <td class="label" width="20%">
              <bean:message bundle='cm.messages' key="cm.content.edit.role.friendlyName"/>:
            </td>
            <td class="labelField" width="80%">
              <html:text size="40" maxlength="80" property="friendlyName"/>
            </td>
          </tr>
          <tr> 
            <td class="label" width="20%">
              <bean:message bundle='cm.messages' key="cm.content.edit.role.description"/>:
            </td>
            <td class="labelField" width="80%">
              <html:textarea  property="description" cols="60" rows="4"/>
            </td>
          </tr>
        </table>

        <div class="pageButtonWrap" align="right">
          <html:reset styleClass="inputButton" property="resetBtn">
            <bean:message bundle='cm.messages' key="button.reset"/>
          </html:reset>
          &nbsp;&nbsp;
          <html:button styleClass="inputButton" property="cancelBtn" onclick="return doCancel(this.form)">
            <bean:message bundle='cm.messages' key="button.cancel"/>
          </html:button>
          <html:submit styleClass="inputButton" property="submitBtn">
            <bean:message bundle='cm.messages' key="button.save"/>
          </html:submit>
        </div>
    </td>
  </tr>
</table>

</html:form>
